﻿@inherits UmbracoViewPage<IEnumerable<IPublishedContent>>
@using MarkdownSharp;

@{
    Markdown md = new Markdown();
    foreach (IPublishedContent item in Model)
    {
        IPublishedContent reffrence = null;
        string filename = "";
        if (item.HasValue("linkToDocument") && item.HasValue("defaultImage"))
        {
            reffrence = item.GetPropertyValue<IPublishedContent>("linkToDocument");
            var mediaItem = Umbraco.Media(item.GetPropertyValue<string>("defaultImage"));
            filename = mediaItem.umbracoFile.src;
        }
        if (reffrence != null && reffrence.Id > 0)
        {
            <div class="col-md-6 docs-section">
                <a href="@reffrence.Url"><img src="@filename" alt="@item.Name"></a>
                <h2 class="anchorjs-heading">@item.Name</h2>
                @MvcHtmlString.Create(md.Transform(reffrence.GetPropertyValue<string>("documentIntroduce")))
            </div>
        }
    }
}